<template>
	<view class="weui-search-bar">
   <view class="weui-search-bar__form">
    <view class="weui-search-bar__box">
      <icon class="weui-icon-search_in-box" type="search" size="14"></icon>
      <input type="text" confirm-type="search" class="weui-search-bar__input" placeholder="搜索" 
             :value="searchData" @input="inputSync" @confirm="searchConfirm" />
    </view>
  </view>
    <block v-if="showSearchBtn">
    </block>
    <view class="weui-search-bar__cancel-btn" @click="searchConfirm">
          <text :key='search'>查询</text>
    </view>
</view>
</template>


<script>
    export default {
      name: 'SearchBar',
      props: {
        searchData: {
          type: String,
          default: ''
        }
      },
      data() {
        return {
        }
      },
      methods: {
        searchConfirm: function() {
          this.$emit('search-confirm');
        },
        inputSync: function(e) {
          console.log(e.detail.value);
          this.$emit("input", e.detail.value);
        }
      }
}
</script>

<style>
  .weui-search-bar {
  position: relative;
  padding: 8px 10px;
  display: flex;
  background-color: #efeff4;
  border-top: 1rpx solid #d7d6dc;
}
.weui-icon-search {
  margin-right: 8px;
  font-size: inherit;
}

.weui-icon-search_in-box {
  position: absolute;
  left: 10px;
  top: 7px;
}
.weui-search-bar__form {
  position: relative;
  flex: auto;
  border-radius: 5px;
  background: #fff;
  border: 1rpx solid #e6e6ea;
}
.weui-search-bar__box {
  position: relative;
  width: 100%;
  z-index: 1;
}

.weui-search-bar__input {
  height: 28px;
  line-height: 28px;
  font-size: 14px;
  padding-left: 30px;
  
}

.weui-icon-clear {
  position: absolute;
  top: 0;
  right: 0;
  padding: 7px 8px;
  font-size: 0;
}
.weui-search-bar__label {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 2;
  border-radius: 3px;
  text-align: center;
  color: #9b9b9b;
  background: #fff;
  line-height: 28px;
}
.weui-search-bar__cancel-btn {
  margin-left: 10px;
  color: #009E7E;
  font-size: 25upx;
  height: 100%;
  top: 0;
  bottom: 0;
  margin: auto 10upx;
  white-space: nowrap; 
}
</style>